package com.huixuebao.after.controller.webAuth;


import com.huixuebao.after.config.RegexConstant;
import com.huixuebao.after.dto.FunctionDTO;
import com.huixuebao.after.service.FunctionService;
import com.huixuebao.common.bean.ApiResult;
import com.huixuebao.common.enumeration.ResultCodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Desc: 功能菜单rest
 * @Author: fatao_yu
 * @Date: 2020-12-16 12:19
 */
@Slf4j
@RestController
@RequestMapping("/hxb/after/function")
public class FunctionController {

    @Autowired
    private FunctionService functionService;

    /**
     * 获取菜单树型结构
     * @Author:fatao_yu
     * @Date: 2020-12-16 12:19
     */
    @GetMapping("/getFunctionTree")
    public ApiResult getFunctionTree(HttpServletRequest request){
        return functionService.getFunctionTree(request);
    }
    /**
     * 用户登陆成功后返回用户菜单权限
     */
    @GetMapping("/getUserFunction")
    public ApiResult getUserFunction(HttpServletRequest request){
        return functionService.getUserFunction(request);
    }

    /**
     * 返回前端一棵树,整个菜单信息
     * @return
     */
    @GetMapping("/getSingTree")
    public ApiResult getSingTree(HttpServletRequest request){ return functionService.getSingTree(request);}

    /**
     * 对菜单进行添加
     * @return
     */
    @PostMapping("/addFunction")
    public ApiResult addFunction(@RequestBody FunctionDTO functionDTO){ return functionService.addFunction(functionDTO);}

    /**
     * 对菜单进行编辑
     * @return
     */
    @PostMapping("/editFunction")
    public ApiResult editFunction(@RequestBody FunctionDTO functionDTO){ return functionService.editFunction(functionDTO);}

    /**
     * 对菜单进行删除
     * @return
     */
    @PostMapping("/deleteFunction")
    public ApiResult deleteFunction(@RequestBody FunctionDTO functionDTO){ return functionService.deleteFunction(functionDTO);}
}
